import request from '@/utils/request'

// 姓名模糊查询
export function GetStudentList(data) {
  if (data.gradeName == '' && data.className == '') {
    return request({
      url: `/student/page?limit=${data.limit}&page=${data.page}&studentName=${data.studentName}`,
      method: 'get'
    })
  }
  if (data.gradeName == '' && data.className != '') {
    return request({
      url: `/student/page?className=${data.className}&limit=${data.limit}&page=${data.page}&studentName=${data.studentName}`,
      method: 'get'
    })
  }
  if (data.gradeName != '' && data.className == '') {
    return request({
      url: `/student/page?gradeName=${data.gradeName}&limit=${data.limit}&page=${data.page}&studentName=${data.studentName}`,
      method: 'get'
    })
  }
  if (data.gradeName != '' && data.className != '') {
    return request({
      url: `/student/page?className=${data.className}&gradeName=${data.gradeName}&limit=${data.limit}&page=${data.page}&studentName=${data.studentName}`,
      method: 'get'
    })
  }
}

// 添加学生信息
export function addStudentList(data) {
  return request({
    url: '/student/addStudent',
    method: 'post',
    data
  })
}

// 删除学生信息
export function deleteStudentList(data) {
  return request({
    url: `/student/deteleStudent?studentId=${data.studentId}`,
    method: 'post'
  })
}

// 批量删除
export function alldeleteStudentList(data) {
  return request({
    url: `/student/deteleStudents?studentIds=${data.item}`,
    method: 'post'
  })
}

// 模板下载
export function downloadStudentList() {
  return request({
    url: '/student/download',
    method: 'post'
  })
}

// 更新学生
export function updateStudentList(data) {
  return request({
    url: '/student/updateStudentBackstage',
    method: 'post',
    data
  })
}

// 文件导入
export function uploadStudentList(data) {
  return request({
    url: `/student/addByFile`,
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: data
  })
}
